<?php

class Admin_Form_Product extends Zend_Form {

    public function __construct($options = null) {
        parent::__construct($options);

        $pid = new Zend_Form_Element_Text('pid');
        $pid->addFilter('StringTrim')
                ->setRequired(true)
                ->addValidator('NotEmpty')                
                ->setAttrib('class', 'form-control')
                ->setDecorators(array('ViewHelper'));

        $titleVi = new Zend_Form_Element_Text('titleVi');
        $titleVi->addFilter('StringTrim')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->setAttrib('class', 'form-control')
                ->setDecorators(array('ViewHelper'));

        $aliasVi = new Zend_Form_Element_Text('aliasVi');
        $aliasVi->addFilter('StringTrim')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->setAttrib('class', 'form-control')
                ->setDecorators(array('ViewHelper'));

        $price = new Zend_Form_Element_Text('price');
        $price->addFilter('StringTrim')
                ->addFilter('Int')
                ->setAttrib('class', 'form-control format-price')
                ->setAttrib('style', 'width:300px')
                ->setDecorators(array('ViewHelper'));
        
        $selloff = new Zend_Form_Element_Text('selloff');
        $selloff->addFilter('StringTrim')
		        ->addFilter('Int')
		        ->setAttrib('class', 'form-control format-price')
		        ->setAttrib('style', 'width:300px')
		        ->setDecorators(array('ViewHelper'));
        
        $amount = new Zend_Form_Element_Text('amount');
        $amount->addFilter('StringTrim')
		        ->addFilter('Int')
		        ->setAttrib('class', 'form-control')
		        ->setAttrib('style', 'width:300px')
		        ->setValue('1')
		        ->setDecorators(array('ViewHelper'));

        $weight = new Zend_Form_Element_Text('weight');
        $weight->addFilter('StringTrim')
                ->addFilter('Int')
                ->addValidator('NotEmpty')
                ->setAttrib('class', 'form-control')
                ->setAttrib('style', 'width:300px')
                ->setValue('999')
                ->setDecorators(array('ViewHelper'));

        $status = new Zend_Form_Element_Radio ( 'status' );
		$status->addFilter('StringTrim')	
				->setAttrib ( 'class', 'grey' )
				->setMultiOptions(array('1' => " Có", '0' => ' Không'))
				->setValue('1')		
				->setDecorators ( array (
						'ViewHelper'
				) );
        
        $productTypeOption ['NORMAL']= 'Bình thường';
        $productTypeOption ['NEW']= 'Mới';
        $productTypeOption ['FEATURED']= 'Nổi bật';
        $productTypeOption['HOT'] = 'Bán chạy';
        //ksort($productTypeOption);
        
        $productType = new Zend_Form_Element_Select('productType');
        $productType->addFilter('StringTrim')
			        ->setMultiOptions($productTypeOption)
			        ->setAttrib('class', 'form-control')
			        ->setAttrib('style', 'width:300px')
			        ->setDecorators(array('ViewHelper'));
			        
      /*   $image = new Zend_Form_Element_File('image');
       	$image->removeDecorator('label')
       		->removeDecorator('HtmlTag')
       		->removeDecorator('DtDdWrapper');
            //->setDestination(PUBLIC_PATH . UPLOAD_PRODUCT_PATH . '/')
            //->addValidator('Size', false, UPLOAD_PRODUCT_SIZE)
            //->addValidator('Extension', false, UPLOAD_PRODUCT_EXTENSION); */
        
        $contentVi = new Zend_Form_Element_Textarea('contentVi');
        $contentVi->setAttrib('COLS', '40')
	        ->setAttrib('ROWS', '2')
	        ->setDecorators(array('ViewHelper'));
                
        $metaTitle = new Zend_Form_Element_Textarea('metaTitle');
        $metaTitle->setAttrib('class', 'product-seo')
                ->setAttrib('id', 'tbMetaTitle')
                ->setAttrib('class', 'form-control')
                ->setAttrib('COLS', '40')
                ->setAttrib('ROWS', '4')
                ->setDecorators(array('ViewHelper'));

        $metaKeyword = new Zend_Form_Element_Textarea('metaKeyword');
        $metaKeyword->setAttrib('class', 'product-seo')
                ->setAttrib('id', 'tbMetaKeywords')
                ->setAttrib('class', 'form-control')
                ->setAttrib('COLS', '40')
                ->setAttrib('ROWS', '4')
                ->setDecorators(array('ViewHelper'));

        $metaDescription = new Zend_Form_Element_Textarea('metaDescription');
        $metaDescription->setAttrib('class', 'product-seo')
                ->setAttrib('id', 'tbMetaDescription')
                ->setAttrib('class', 'form-control')
                ->setAttrib('COLS', '40')
                ->setAttrib('ROWS', '4')
                ->setDecorators(array('ViewHelper'));

        $arrElement = array(
            $pid,
            $titleVi,
            $aliasVi,
        	$price,
        	$selloff,
        	$amount,
            $weight,
            $status,  
        	$productType,
            //$image,
        	$contentVi,
            $metaTitle,
            $metaKeyword,
            $metaDescription,
        );

        if (ENGLISH == 1) {
            $titleEn = new Zend_Form_Element_Text('titleEn');
            $titleEn->addFilter('StringTrim')
                    ->setRequired(true)
                    ->addValidator('NotEmpty')
                    ->setAttrib('class', 'form-control')
                    ->setDecorators(array('ViewHelper'));

            $aliasEn = new Zend_Form_Element_Text('aliasEn');
            $aliasEn->addFilter('StringTrim')
                    ->setRequired(true)
                    ->addValidator('NotEmpty')
                    ->setAttrib('class', 'form-control')
                    ->setDecorators(array('ViewHelper'));

            
            $contentEn = new Zend_Form_Element_Textarea('contentEn');
            $contentEn->setAttrib('COLS', '40')
                    ->setAttrib('ROWS', '2')
                    ->setDecorators(array('ViewHelper'));
             
            $arrElement[] = $titleEn;
            $arrElement[] = $aliasEn;
            
            $arrElement[] = $contentEn;
        }

        $this->addElements($arrElement);
    }

}
